package com.muyan.design.flyweight.good;


public class FlyweightPattern {
    Flyweight fly1;
    Flyweight fly2;
    Flyweight fly3;
    Flyweight fly4;
    Flyweight fly5;
    Flyweight fly6;

    /** */
    /**
     * Creates a new instance of FlyweightPattern
     */
    public FlyweightPattern() {
        fly1 = FlyweightFactory.getFlyWeight("Google");
        fly2 = FlyweightFactory.getFlyWeight("Qutr");
        fly3 = FlyweightFactory.getFlyWeight("Google");
        fly4 = FlyweightFactory.getFlyWeight("Google");
        fly5 = FlyweightFactory.getFlyWeight("Google");
        fly6 = FlyweightFactory.getFlyWeight("Google");
    }

    public void showFlyweight() {
        fly1.operation();
        fly2.operation();
        fly3.operation();
        fly4.operation();
        fly5.operation();
        fly6.operation();
        int objSize = FlyweightFactory.getFlyweightSize();
        System.out.println("objSize = " + objSize);
    }

    public static void main(String[] args) {
        System.out.println("The FlyWeight Pattern!");
        FlyweightPattern fp = new FlyweightPattern();
        fp.showFlyweight();
    }
}
